package kr.saeildamil.beatboxmix;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings.System;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;

public class MainSelect extends Activity {
	int width;
	int height;
	LinearLayout liner;
	LayoutInflater inflater;
	LinearLayout.LayoutParams paramlinear;
	Window win;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		win = getWindow();
		width = win.getWindowManager().getDefaultDisplay().getWidth();
		height = win.getWindowManager().getDefaultDisplay().getHeight();
		win.requestFeature(Window.FEATURE_NO_TITLE);
		win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
		setContentView(R.layout.activity_main);

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		switch (keyCode) {
		case KeyEvent.KEYCODE_BACK:
			new AlertDialog.Builder(this)
					.setIcon(android.R.drawable.ic_dialog_alert)
					.setTitle("확인")
					.setMessage("프로그램을 종료하시겠습니까?")
					.setPositiveButton("예",
							new DialogInterface.OnClickListener() {

								@Override
								public void onClick(DialogInterface dialog,
										int which) {
									moveTaskToBack(true);
									
									/*android.os.Process
											.killProcess(android.os.Process
													.myPid());*/

								}
							}).setNegativeButton("아니오", null).show();
		}

		return true;

	}

	public void mOnClick(View v) {

		switch (v.getId()) {
		case R.id.mainselect_start:
			startActivity(new Intent(this, MainIntro2.class));
			break;
		case R.id.mainselect_guide:
			inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			liner = (LinearLayout) inflater.inflate(R.layout.popup, null);
			LinearLayout.LayoutParams paramlinear = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.MATCH_PARENT);
			win.addContentView(liner, paramlinear);
			liner.setVisibility(View.VISIBLE);
			break;
		case R.id.mainselect_select:
			startActivity(new Intent(this, MainIntro2.class));
			overridePendingTransition(R.anim.start_enter, R.anim.start_exit);
			break;
		case R.id.mainimage7_exitbtn:
			liner.setVisibility(View.GONE);
			break;
		}
	}
}
